package migrations

import (
	"github.com/goravel/framework/contracts/database/schema"
	"github.com/goravel/framework/facades"
)

type M20250703094812CreateCategoryTable struct {
}

// Signature The unique signature for the migration.
func (r *M20250703094812CreateCategoryTable) Signature() string {
	return "20250703094812_create_category_table"
}

// Up Run the migrations.
func (r *M20250703094812CreateCategoryTable) Up() error {
	if !facades.Schema().HasTable("category") {
		return facades.Schema().Create("category", func(table schema.Blueprint) {
			table.ID()
			table.String("biz").Default("").Comment("业务代码")
			table.String("name").Comment("名称")
			table.Integer("parent_id").Default(0).Comment("父ID")
			table.Integer("order_num").Default(0).Comment("排序")
			table.SmallInteger("status").Default(1).Comment("状态")
			table.Integer("creator_id").Default(0).Comment("创建人ID")
			table.String("creator_name").Default("").Comment("创建人名称")
			table.TimestampsTz()
		})
	}

	return nil
}

// Down Reverse the migrations.
func (r *M20250703094812CreateCategoryTable) Down() error {
	return facades.Schema().DropIfExists("category")
}
